from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `chat_exclusive_key` ADD `use_count` INT NOT NULL  COMMENT '已用次数' DEFAULT 0;
        ALTER TABLE `chat_exclusive_key` ADD `user_id_id` INT;
        ALTER TABLE `chat_exclusive_key` ALTER COLUMN `count` SET DEFAULT 200;
        ALTER TABLE `chat_exclusive_key` ADD CONSTRAINT `fk_chat_exc_zhan_use_d5fbf605` FOREIGN KEY (`user_id_id`) REFERENCES `zhan_user` (`id`) ON DELETE CASCADE;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `chat_exclusive_key` DROP FOREIGN KEY `fk_chat_exc_zhan_use_d5fbf605`;
        ALTER TABLE `chat_exclusive_key` DROP COLUMN `use_count`;
        ALTER TABLE `chat_exclusive_key` DROP COLUMN `user_id_id`;
        ALTER TABLE `chat_exclusive_key` ALTER COLUMN `count` DROP DEFAULT;"""
